<template>
    <div>
        <van-tabs :class="{isfixed:isFixed}">
            <van-tab  v-for="item in professionList.rows" :title="item.professionName"
                :key="item.id ">
                内容 {{ item.id }}
            </van-tab>
        </van-tabs>
    </div>
</template>

<script>
import { professionList } from "../../../service/job/jobservice"

export default {
    data() {
        return {
            isFixed: false,
            professionList: [],
        
        }
    },
    async created() {
        let { data } = await professionList()
   
        this.professionList = data;
 
        // console.log(JSON.parse(JSON.stringify(data.rows)));
    
    },
    methods: {
        // 吸顶效果
        checkScroll() {
            let scrollTop = document.documentElement.scrollTop;//滚动的距离
            // let mainHeight = document.querySelector(".main").clientHeight;
            // let listHeight = document.querySelector(".list").clientHeight;
            if (scrollTop >=235) {
                this.isFixed = true;
            } else {
                this.isFixed = false;
            }
        },
    },
    mounted(){
    window.addEventListener("scroll",this.checkScroll);
  },
  destroyed(){
    window.removeEventListener("scroll",this.checkScroll)
  },

}
</script>

<style>
.isfixed{
    position: fixed;
    left: 0;
    top: 46px;
  }

</style>